package com.ah.proj.bus.address.service;

import java.util.*;

import com.ah.proj.bean.Address;
import com.ah.proj.bus.address.dao.AddressDao;

public class AddressService {
	private AddressDao dao = new AddressDao();

	public List<Address> getAll() {
		return dao.getAll();
	}

	public Address getById(int id) {
		return dao.getById(id);
	}

	public boolean insert(Address addr) {
		return dao.insert(addr);
	}

	public boolean update(Address addr) {
		return dao.update(addr);
	}

	// 逻辑删除
	public boolean delete(int id) {
		Address addr = dao.getById(id);
		addr.setIsDelete("1");
		return dao.update(addr);
	}

	// 保存（新增/更新）
	public boolean save(Address addr) {
		if (addr.getId() > 0) {
			return dao.update(addr);
		} else {
			return dao.insert(addr);
		}
	}
}